package com.panopset.gui;

import java.awt.GridBagConstraints;


/**
 * Supply grid bag constraints for successive grid bag rows.
 *
 * @author Karl Dinwiddie.
 *
 */
public final class RowConstraints {

    /**
     * Column constraints.
     */
    private final GridBagConstraints[] gbc;

    /**
     * @return Next row of constraints.
     */
    public GridBagConstraints[] getNextRowConstraints() {
        GridBagConstraints[] rtn = new GridBagConstraints[gbc.length];
        for (int i = 0; i < gbc.length; i++) {
            rtn[i] = (GridBagConstraints) gbc[i].clone();
            gbc[i].gridy++;
        }
        return rtn;
    }

    /**
     * @param columns Number of columns.
     */
    public RowConstraints(final int columns) {
        gbc = new GridBagConstraints[columns];
        for (int i = 0; i < gbc.length; i++) {
            gbc[i] = new GridBagConstraints();
            gbc[i].gridx = i;
            gbc[i].gridy = 0;
            gbc[i].anchor = GridBagConstraints.EAST;
            gbc[i].fill = GridBagConstraints.HORIZONTAL;
            gbc[i].weightx = 1.0;
        }
    }
}
